package com.znzz.ar;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.znzz.domain.User;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class ActiveRecordTestCase {
    @Test
    public void testSelect() {
        User user = new User();
        user.setId("1231212");
        User user1 = user.selectById();
        System.out.println(user1);
    }

    @Test
    public void testSave() {
        User user = new User();
        user.setSex("男");
        user.setAddress("成都");
        user.setPassword("qwq qwq qwq");
        user.setName("赵无极");
        boolean bool = user.insert();
        System.out.println(bool);
    }

    @Test
    public void testUpdate() {
        User user = new User();
        user.setSex("男");
        user.setAddress("成都");
        user.setPassword("qwq- qwq- qwq");
        user.setAge(20);
        user.setName("小神童");
        user.setId("c7449c4ffd6bfa57145d6b29402a3ed2");
        boolean bool = user.updateById();
        System.out.println(bool);
    }


    @Test
    public void testDelete() {
        User user = new User();
        user.setId("adds");
        user.deleteById();
    }

    @Test
    public void testGetAll() {
        User user = new User();
        List<User> users = user.selectAll();
        users.forEach(System.out::println);
    }

    @Test
    public void testGetByAge() {
        User user = new User();
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("age", 20).or().eq("name", "Tom");
        List<User> userList = user.selectList(wrapper);
        for (User user1 : userList) {
            System.out.println(user1);
        }
    }


}
